<!DOCTYPE>
<html>
	<head>
		<include file="Public/head" />
		<link rel="stylesheet" href="__PUBLIC__/Manage/css/table.css">
		<script type="text/javascript" src="__PUBLIC__/Manage/js/wangEditor/wangEditor.min.js"></script>
		<title>合同设置</title>
		<style type="text/css">
			.layer-anim{
				top:180px !important;
			}
		</style>
	</head>

	<body>
		<div class="nestable">
			<div class="console-title console-title-border drds-detail-title clearfix">
				<h5>合同设置</h5>
			</div>
			<div class="public-selectArea public-selectArea1 margin_10">
				<form action="{:U('Setting/contract')}" method="post">
					
					<div class="clearfix clearfix1">
						<div class="wp_box  col-xs-8">
							<dt>合同模板：</dt>
							<dl>
								<php>$contractTpl = empty(C('contractTpl'))?'':htmlspecialchars_decode(htmlspecialchars_decode(C('contractTpl')));</php>
								<dd>
									<input type="hidden" name="contractTpl" value="" />
									<div class="editor" id="contractTpl" style="margin-left: 0px;">{$contractTpl|default=''}</div>
								</dd>
							</dl>
							<em class="tishi">
								合同中可使用模板变量，变量使用时以“｛｝”包含即可自动生成<br />
								目前可使用变量：<br />
								借款人名称、借款人身份证号、借款人手机号、借款金额大写、借款金额小写、借款期限类型、
								借款利息、借款开始日、借款结束日、借款人用户名、收款银行账号、收款银行开户行、逾期利息、借款人签名、合同签订日期、借款人住所
								<br />
							</em>
						</div>
					</div>
					
					<div class="clearfix clearfix1">
						<div class="wp_box  col-xs-8">
							<dt>服务协议：</dt>
							<dl>
								<php>$agreementTpl = empty(C('agreementTpl'))?'':htmlspecialchars_decode(htmlspecialchars_decode(C('agreementTpl')));</php>
								<dd>
									<input type="hidden" name="agreementTpl" value="" />
									<div class="editor" id="agreementTpl" style="margin-left: 0px;">{$agreementTpl|default=''}</div>
								</dd>
							</dl>
						</div>
					</div>
					
				</form>

				<div class="btnArea margin_20">
					<a href="javascript:;" class="btn btn-grayBg">
						<span class="public-label">提交</span>
					</a>
				</div>
			</div>
		</div>
	</body>
	<script language="javascript">
    
    function createSealEx(){
       var dw = document.getElementById("dw");
       var edw = document.getElementById("edw");
       var mdtext = document.getElementById("mdtext");  
       var tuzhangdiv = document.getElementById("tuzhangdiv"); 
       tuzhangdiv.innerHTML ="<canvas id='canvas' width='160' height='160'></canvas>";
       createSeal('canvas',dw.value,edw.value,mdtext.value);
       
       
    }
    //function createSealEx2(){
       var dw = document.getElementById("dw");
       var edw = document.getElementById("edw");
       var mdtext = document.getElementById("mdtext");  
       var tuzhangdiv = document.getElementById("tuzhangdiv"); 
       tuzhangdiv.innerHTML ="<canvas id='canvas' width='160' height='160'></canvas>";
       createSeal11('canvas',dw.value,mdtext.value);
       
    //}
    
    function createSeal11(id,company,name){
    
    var canvas = document.getElementById(id);  
    var context = canvas.getContext('2d');
    
    // 绘制印章边框   
    var width=canvas.width/2;
    var height=canvas.height/2;
    context.lineWidth=2;
    context.strokeStyle="#f00";
    context.beginPath();
    context.arc(width,height,78,0,Math.PI*2);
    context.stroke();
    context.save(); 
    
    context.lineWidth=1;
    context.strokeStyle="#f00";
    context.beginPath();
    context.arc(width,height,75,0,Math.PI*2);
    context.stroke();
    context.save(); 

    //画五角星
    create5star(context,width,height,25,"#f00",0);

    // 绘制印章名称   
    context.font = '18px Helvetica';
    context.textBaseline = 'middle';//设置文本的垂直对齐方式
    context.textAlign = 'center'; //设置文本的水平对对齐方式
    context.lineWidth=1;
    context.fillStyle = '#f00';
    context.fillText(name,width,height+53);

    // 绘制印章单位   
    context.translate(width,height);// 平移到此位置,
    context.font = '20px Helvetica'
    var count = company.length;// 字数   
    var angle = 4*Math.PI/(3*(count - 1));// 字间角度   
    var chars = company.split("");   
    var c;
    for (var i = 0; i < count; i++){
        c = chars[i];// 需要绘制的字符   
        if(i==0)
            context.rotate(5*Math.PI/6);
        else
          context.rotate(angle);
        context.save(); 
        context.translate(64, 0);// 平移到此位置,此时字和x轴垂直   
        context.rotate(Math.PI/2);// 旋转90度,让字平行于x轴   
        context.fillText(c,0, 5);// 此点为字的中心点   
        context.restore();             
    }

    
}

    
   function createSeal(id,company,ecompany,name){
        var canvas = document.getElementById(id); 
        var context = canvas.getContext('2d');    
        context.translate(0,0);//移动坐标原点 
        // 绘制印章边框   
        var width=canvas.width/2;
        var height=canvas.height/2;
        //边框1
        context.lineWidth=2;
        context.strokeStyle="#f00";
        context.beginPath();
        context.arc(width,height,78,0,Math.PI*2);
        context.stroke();
        context.save(); 
        
        //边框2
        context.lineWidth=1;
        context.strokeStyle="#f00";
        context.beginPath();
        context.arc(width,height,63,0,Math.PI*2);
        context.stroke();
        context.save();
    
    
        //画五角星
        create5star(context,width,height,20,"#f00",0);
        
        // 绘制印章类型
        context.font = 'bolder 15px SimSun';
        context.textBaseline = 'middle';//设置文本的垂直对齐方式
        context.textAlign = 'center'; //设置文本的水平对对齐方式
        context.lineWidth=1;
        context.fillStyle = '#f00';
        context.fillText(name,width,height+50);
        
        
        // 绘制印章中文单位   
        context.translate(width,height);// 平移到此位置, 
        context.font = 'bolder 18px SimSun'
        var count = company.length;// 字数   
        var angle = 4*Math.PI/(3*(count-1));// 字间角度   
        var chars = company.split("");   
        var c;
        for (var i = 0; i < count; i++){
            c = chars[i];// 需要绘制的字符   
            if(i==0)
                context.rotate(5*Math.PI/6);
            else
              context.rotate(angle);
            context.save(); 
            // 平移到此位置,此时字和x轴垂直，第一个参数是与圆外边的距离，越大距离越近   
            context.translate(52, 0);
            context.rotate(Math.PI/2);// 旋转90度,让字平行于x轴   
            context.fillText(c,0, 5);// 此点为字的中心点   
            context.restore();             
        }
        //绘制印章英文单位
        context.translate(width-80,height-80);// 平移到此位置,
        context.font = 'bolder 10px SimSun';
        var ecount = ecompany.length;// 字数   
        var eangle = (5*Math.PI)/(3*(ecount));// 字间角度   
        var echars = ecompany.split("");   
        var ec;
        for (var j = 0; j < ecount; j++){
            ec = echars[j];// 需要绘制的字符   
            if(j==0)
                context.rotate(6*Math.PI/7-1);
            else
              context.rotate(eangle);
            context.save(); 
            // 平移到此位置,此时字和x轴垂直，第一个参数是与圆外边的距离，越大距离越近   
            context.translate(74, 0);
            context.rotate(Math.PI/2);// 旋转90度,让字平行于x轴   
            context.fillText(ec,0, 4.8);// 此点为字的中心点   
            context.restore();             
        }
    
 
} 

 //绘制五角星  
   function create5star(context,sx,sy,radius,color,rotato){
        context.save();  
        context.fillStyle=color;  
        context.translate(sx,sy);//移动坐标原点  
        context.rotate(Math.PI+rotato);//旋转  
        context.beginPath();//创建路径  
        var x = Math.sin(0);  
        var y= Math.cos(0);  
        var dig = Math.PI/5 *4;  
        for(var i = 0;i< 5;i++){ 
         var x = Math.sin(i*dig);  
         var y = Math.cos(i*dig);  
         context.lineTo(x*radius,y*radius);  
        }   
        context.closePath();  
        context.stroke();  
        context.fill();  
        context.restore();  
    }
   
   </script>
	<script type="text/javascript">
		$(function(){
			var E = window.wangEditor;
			var editor1 = new E('#contractTpl');
			var editor2 = new E('#agreementTpl');
			editor1.create();
			editor2.create();
			$(".btnArea a").on('click',function(){
				$("input[name='contractTpl']").val(editor1.txt.html());
				$("input[name='agreementTpl']").val(editor2.txt.html());
				cvphp.submit($("form"),function(data){
					if(data.status!=1){
						layer.msg(data.info);
					}else{
						layer.alert('保存成功');
					}
				});
			});
			
		});
	</script>
</html>